#include <memory>
#include <string>
#include <mutex>
enum GlobalLogLevel {
    GlobalLogLevel_Debug = 0,
    GlobalLogLevel_Info = 1,
    GlobalLogLevel_Warning = 2,
    GlobalLogLevel_Error = 3,
    GlobalLogLevel_Fatal = 4,
};

class GlobalLog {
public:
    GlobalLog();
    ~GlobalLog();
    static std::shared_ptr<GlobalLog> getGlobalLog();
public:
    void Init(GlobalLogLevel level, const std::string& log_file);
    void Log(GlobalLogLevel level, const std::string& message, bool flush=true);
    void LogDebug(const std::string& message, bool flush=true);
    void LogInfo(const std::string& message, bool flush=true);
    void LogWarning(const std::string& message, bool flush=true);
    void LogError(const std::string& message, bool flush=true);
    void LogFatal(const std::string& message, bool flush=true);

private:
    static std::mutex s_log_mutex;
    static std::shared_ptr<GlobalLog> s_global_log;
    bool m_initialized;
    GlobalLogLevel m_log_level;
};

inline std::shared_ptr<GlobalLog> getGlobalLog(){
    return GlobalLog::getGlobalLog();
}
